import { _decorator, Label } from 'cc';
import { SpriteFramesComponent } from '../SpriteFramesComponent';
import { DataItemComponent } from '../../../Core/DataItemLayout';
const { ccclass, property } = _decorator;

@ccclass('MailBoxGridItem')
export class MailBoxGridItem extends DataItemComponent<{icon:number, quality:number, count:number}> {
    @property(SpriteFramesComponent)
    quality : SpriteFramesComponent;

    @property(SpriteFramesComponent)
    icon : SpriteFramesComponent;

    @property(Label)
    numLabel : Label;

    setData(data : {icon:number, quality:number, count:number}){
        this.quality.selectSpritFrame(data.quality)
        this.icon.selectSpritFrame(data.icon)

        if(data.count){
            this.numLabel.node.active = true
            this.numLabel.string = `x${data.count}`
        }else{
            this.numLabel.node.active = false
        }
    }
}


